<template>
	<view class="page-my-collect">
		<u-navbar :title="title" back-icon-color="#000" :border-bottom="false"
		title-size="36" title-color="#000" title-bold></u-navbar> 
		<view class="list-warp">
			<block v-for="(item,index) in list">
				<leftImgRightText :item="item" @goDetail="goDetail"></leftImgRightText>
				<u-line color="#ebebeb" v-if="list.length != (index+1)"></u-line>
			</block>
		</view>
	</view>
</template>

<script>
	import {commonGet} from '@/api/commonapi.js';
	import leftImgRightText from "@/components/common/left-img-right-text.vue"
	export default {
		components:{
			leftImgRightText
		},
		data() {
			return {
				$baseUrl:"",
				stype:"",
				list:[],
				title:"",
				cmd:"",
				sysMemID:"",
				pagesize:10
			}
		},
		onLoad(options) {
			this.$baseUrl = this.baseUrl
			this.cmd = options.cmd
			this.stype = options.stype
			this.title = options.title
			if(this.$store.state.userIn){
				this.sysMemID = this.$store.state.userIn.id
			}
			this.getList()
		},
		methods: {
			getList(pagesize){
				let _this = this
				let query = {
					ak:_this.$store.state.token,
					cmd:_this.cmd,
					para:JSON.stringify({
						sysMemID:_this.sysMemID,
						stype:_this.stype,
						pageindex: 1,
						pagesize: pagesize || 10
					})
				}
				commonGet(query,({Data})=>{
					console.log(Data)
					_this.list = Data.Data
				})
			},
			goDetail(item){
				let _this = this
				if(this.title == "我的评价"){
					switch (item.pageid){
						case "3309": _this.$u.route('', {id: item.keyid});break;
						case "3314": _this.$u.route('/pages/HomeLnner/DeviceDetails/DeviceDetails', {id: item.keyid});break;
						case "2153": _this.$u.route('/pages/circle/circle-detail/circle-detail', {id: item.keyid});break;
						case "3307": _this.$u.route('/pages/index/homeInfo-detail/homeInfo-detail', {id: item.keyid});break;
						case "3305": _this.$u.route('/pages/HomeLnner/AtlasDetails/AtlasDetails', {id: item.keyid});break;
						case "3310": _this.$u.route('/pages/HomeLnner/PracticeDetails/PracticeDetails', {id: item.keyid});break;
						case "3312": _this.$u.route('', {id: item.keyid});break;
						case "3315": _this.$u.route('', {id: item.keyid});
					}
				}else{
					switch (item.spageid){
						case "3309": _this.$u.route('', {id: item.skeyid});break;
						case "3314": _this.$u.route('/pages/HomeLnner/DeviceDetails/DeviceDetails', {id: item.skeyid});break;
						case "2153": _this.$u.route('/pages/circle/circle-detail/circle-detail', {id: item.skeyid});break;
						case "3307": _this.$u.route('/pages/index/homeInfo-detail/homeInfo-detail', {id: item.skeyid});break;
						case "3305": _this.$u.route('/pages/HomeLnner/AtlasDetails/AtlasDetails', {id: item.skeyid});break;
						case "3310": _this.$u.route('/pages/HomeLnner/PracticeDetails/PracticeDetails', {id: item.skeyid});break;
						case "3312": _this.$u.route('', {id: item.skeyid});break;
						case "3315": _this.$u.route('', {id: item.skeyid});
					}
				}
			}
		},
		onPullDownRefresh() {
			this.pagesize = 10
			this.getList(this.pagesize)
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.pagesize += 10
			this.getList(this.pagesize)
		}
	}
</script>

<style lang="scss" scoped>
	.page-my-collect{
		overflow: hidden;
	}
	.list-warp{
		padding: 0 30rpx;
	}
</style>
